package com.luguangtao.config;

//import com.luguangtao.filter.MyGateWayFilter;
import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * @类名: com.luguangtao.config
 * @作者: lgt
 * @创建时间: 2019-12-05 21:38
 * @描述:
 **/
/*@Configuration
public class TestConfig  {

    @Bean("MyRemoteAddrKeyResolver")
    public MyRemoteAddrKeyResolver getKey(){
        return new MyRemoteAddrKeyResolver();
    }


    //路由绑定过滤器
    @Bean
    public RouteLocator getRouteLocator(RouteLocatorBuilder routeLocatorBuilder){
        RouteLocatorBuilder.Builder route = routeLocatorBuilder.routes().route(predicateSpec -> predicateSpec
                .path("/api/client2/**")
                .filters(f -> f.stripPrefix(2).filter(getMyGateWayFilter()))
                .uri("http://localhost:10002")
                .id("client-2"));
        return route.build();
    }

    private GatewayFilter getMyGateWayFilter() {
        return new MyGateWayFilter();
    }

}*/
